#include "checktable.h"
#include "ui_checktable.h"
#include "util.h"
#include "checktableitem.h"
CheckTable::CheckTable(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::CheckTable)
{
    ui->setupUi(this);

    // 显示审核页面
    updateCheckTable();
    ui->videoStatus->addItem("全部分类");
    ui->videoStatus->addItem("待审核");
    ui->videoStatus->addItem("审核通过");
    ui->videoStatus->addItem("审核驳回");
    ui->videoStatus->addItem("已下架");
    ui->videoStatus->addItem("转码中");
    ui->videoStatus->setCurrentIndex(0);
    // 给视频用户编辑框添加限制
    QRegularExpression regExp("^[0-9a-f]{4}-[0-9a-f]{8}-[0-9a-f]{4}$");
    QValidator* validator = new QRegularExpressionValidator(regExp, this);
    // 将正则表达式校验器设置到编辑框中，用户在userIdEdit中输入的内容就会被验证是否符合正则表达式的规则
    ui->userIdEdit->setValidator(validator);

    connect(ui->resetBtn, &QPushButton::clicked, this, &CheckTable::onResetBtnClicked);
    connect(ui->queryBtn, &QPushButton::clicked, this, &CheckTable::onQueryBtnClicked);

    // 创建分页器并显示
    paginator = new Paginator(10, ui->PaginatorArea);
    paginator->move(0, 15);
    paginator->show();
}

CheckTable::~CheckTable()
{
    delete ui;
}

void CheckTable::updateCheckTable()
{
    // 将checkTableItem添加到页面中
    for(int i = 0; i < 10; i++)
    {
        CheckTableItem* item = new CheckTableItem(this);
        ui->layout->addWidget(item);
    }
}

void CheckTable::onResetBtnClicked()
{
    // 设置按钮样式高亮：重置按钮高亮、查询按钮背景白色
    ui->resetBtn->setStyleSheet("background-color : #3ECEFF;"
                                "border-radius : 4px;"
                                "font-family : 微软雅黑;"
                                "font-size : 14px;"
                                "color : #FFFFFF;");

    ui->queryBtn->setStyleSheet("background-color : #FFFFFF;"
                                "border-radius : 4px;"
                                "border: 1px solid #DCDEE0;"
                                "font-family : 微软雅黑;"
                                "font-size : 14px;"
                                "color : #222222;");
    ui->userIdEdit->setText("");
    ui->videoStatus->setCurrentIndex(0);
    LOG()<<"重置按钮点击...";
}

void CheckTable::onQueryBtnClicked()
{
    // 设置按钮样式高亮：重置按钮高亮、查询按钮背景白色
    ui->queryBtn->setStyleSheet("background-color : #3ECEFF;"
                                "border-radius : 4px;"
                                "font-family : 微软雅黑;"
                                "font-size : 14px;"
                                "color : #FFFFFF;");

    ui->resetBtn->setStyleSheet("background-color : #FFFFFF;"
                                "border-radius : 4px;"
                                "border: 1px solid #DCDEE0;"
                                "font-family : 微软雅黑;"
                                "font-size : 14px;"
                                "color : #222222;");
    LOG()<<"查询按钮点击...";
}


